import pandas as pd


# 读取Excel文件
df = pd.read_excel('账户交易记录-20241028092155576.xlsx', sheet_name='账户交易记录')

def create_sql(row):
    sub = row['差额']
    rounded_difference = round(row['服务费'], 2)

    if sub != 0 :
        return "账不对，不予处理"
    else:
        return f"update money_tran_settle_statistics set ABLE_INVOICE_FEE = ABLE_INVOICE_FEE + {rounded_difference} where DEPT_ID = {row['dept_id']} and PARK_ID = 23;"


# 应用函数到DataFrame，生成新的列
df['SQL'] = df.apply(create_sql, axis=1)

# 如果需要保存到新的Excel文件
df.to_excel('处理后账户交易记录-20241028092155576.xlsx', index=False)